<?php
if( is_admin() ) {

	/* Start of: WordPress Administration */

	/* WordPress Administration menu */
	function wpsc_fs_add_modules_admin_pages( $page_hooks,$base_page ) {

		$page_hooks[] = add_submenu_page( $base_page, __( 'Facebook Share for WP e-Commerce', 'wpsc_fs' ), __( 'Facebook Share', 'wpsc_fs' ), 7, 'wpsc_fs', 'wpsc_fs_html_page' );
		return $page_hooks;

	}
	add_filter( 'wpsc_additional_pages', 'wpsc_fs_add_modules_admin_pages', 10, 2 );

	/* End of: WordPress Administration */

} else {

	/* Start of: Storefront */

	function wpsc_fs_init() {

		global $wpsc_query;

		$position = get_option( 'wpsc_fs_position' );
		$display_singleproduct = get_option( 'wpsc_fs_display_singleproduct' );
		$display_productspage = get_option( 'wpsc_fs_display_productspage' );

		if( $wpsc_query->is_single ) {
			if( $display_singleproduct ) {
				if( $position <> 'manual' )
					wpsc_fs_html_product();
			}
		} else {
			if( $display_productspage ) {
				if( $position <> 'manual' )
					wpsc_fs_html_product();
			}
		}

	}

	function wpsc_fs_html_product() {

		global $wpsc_query;

		if( $wpsc_query->is_single ) {
			$page = wpsc_this_page_url();
		} else {
			$page = wpsc_the_product_permalink();
		}
		if( is_ssl() )
			$page = str_replace( 'http', 'https', $page );

		$output = '<a name="fb_share" type="box_count" share_url="' . $page . '"></a>';
		echo $output;

	}

	/* End of: Storefront */

}
?>
